unit uRegCommon;

interface
Uses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls, Registry;

// Various standard constants
const
      CONST_HKCR        =       'HKEY_CLASSES_ROOT';
      CONST_HKCU        =       'HKEY_CURRENT_USER';
      CONST_HKLM        =       'HKEY_LOCAL_MACHINE';
      CONST_HKU         =       'HKEY_USERS';
      CONST_HKCC        =       'HKEY_CURRENT_CONFIG';
//      CONST_WOW64_WARN  =       'You are running under a 64 bit Windows system, this program is 32bit and must use WoW64 to access the registiry';



// This function is used to check if we are running under Wow64 system on
// 64bit Windows
function IsWow64: Boolean;




implementation

function IsWow64: Boolean;
type
  TIsWow64Process = function( // Type of IsWow64Process API fn
    Handle: Windows.THandle; var Res: Windows.BOOL
  ): Windows.BOOL; stdcall;
var
  IsWow64Result: Windows.BOOL;      // Result from IsWow64Process
  IsWow64Process: TIsWow64Process;  // IsWow64Process fn reference
begin
  // Try to load required function from kernel32
  IsWow64Process := Windows.GetProcAddress(
    Windows.GetModuleHandle('kernel32.dll'), 'IsWow64Process'
  );
  if Assigned(IsWow64Process) then
  begin
    // Function is implemented: call it
    if not IsWow64Process(
      Windows.GetCurrentProcess, IsWow64Result
    ) then
      raise SysUtils.Exception.Create('IsWow64: bad process handle');
    // Return result of function
    Result := IsWow64Result;
  end
  else
    // Function not implemented: can't be running on Wow64
    Result := False;
end;


end.
